package cn.fl.preinsroute.service.impl;

import cmm.mid.core.framework.dto.BaseParamDTO;
import cmm.mid.core.framework.page.Pager;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.cmm.base.framework.utils.CollectionUtils;
import cn.cmm.base.framework.utils.StringUtils;
import cn.fl.preinsroute.api.IPreRouteAddApiService;
import cn.fl.preinsroute.api.IPreRouteModifyApiService;
import cn.fl.preinsroute.api.IPreRouteQueryApiService;
import cn.fl.preinsroute.api.IPreRouteRemoveApiService;
import cn.fl.preinsroute.dto.PreRouteBscInfoDTO;
import cn.fl.preinsroute.service.IPreRouteBscInfoService;
import cn.fl.preinsroute.transform.PreRouteBscInfoVOTransform;
import cn.fl.preinsroute.vo.PreRouteBscInfoVO;
import com.alibaba.fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 资管路由预筛选基础信息表 客户端服务层接口实现
 * @Description: 业务层方法名称前缀：新增：add* 删除：remove* 修改：modify* 查询对象：select* get* 批量：batch* 查询集合：search*
 */
@Service
public class PreRouteBscInfoServiceImpl implements IPreRouteBscInfoService {

	@Autowired
	private IPreRouteQueryApiService preRouteQueryApiService ;
	@Autowired
	private IPreRouteRemoveApiService preRouteRemoveApiService ;
	@Autowired
	private IPreRouteAddApiService preRouteAddApiService ;
	@Autowired
	private IPreRouteModifyApiService preRouteModifyApiService ;

	@Override
	public PreRouteBscInfoVO selectById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			return null;
		}
		//TODO 业务逻辑
		PreRouteBscInfoDTO dto = null;//this.自定义ApiService.selectById(id);
		return PreRouteBscInfoVOTransform.toVO(dto);
	}

	@Override
	public Long add(PreRouteBscInfoVO entity) throws BaseException{
		if(null == entity){
			return null;
		}
		return this.preRouteAddApiService.addPreRouteBscInfo(PreRouteBscInfoVOTransform.toDTO(entity));
	}

	@Override
	public boolean removeById(Long id) throws BaseException{
		if(StringUtils.isEmpty(id)){
			return false;
		}
		return this.preRouteRemoveApiService.removePreRouteInfo(id);
	}
	
	/**
     * 删除
     * @param ids
     * @return
     */
    public boolean removeByIds(List<Long> ids)throws BaseException{
    	if(CollectionUtils.isEmpty(ids)){
			return false;
		};
		return false;
    }

	@Override
	public Long modify(PreRouteBscInfoVO entity) throws BaseException{
		if(null == entity){
			return null;
		}
		Long routeId = preRouteModifyApiService.modifyPreRouteBscInfo(PreRouteBscInfoVOTransform.toDTO(entity));
		return routeId;
	}

	@Override
	public Pager searchListPage(Pager page) throws BaseException{
		return preRouteQueryApiService.selectPreRouteBscInfoListPage(page);
	}

	@Override
	public PreRouteBscInfoVO selectPreRouteBscInfoAllById(Long routeId) {
		BaseParamDTO baseParamDTO = new BaseParamDTO() ;
		PreRouteBscInfoDTO preRouteBscInfoDTO = preRouteQueryApiService.selectPreRouteBscInfoAllById(routeId, baseParamDTO);
		BaseLogUtils.newWebLogger("查询筛选结果，routeId:" + routeId + ",preRouteBscInfoDTO:"+ JSON.toJSONString(preRouteBscInfoDTO)).info();
		if (preRouteBscInfoDTO == null){
			BaseLogUtils.newWebLogger("查询预筛选结果失败").info();
		}
		PreRouteBscInfoVO preRouteBscInfoVO = PreRouteBscInfoVOTransform.toVO(preRouteBscInfoDTO);
		return preRouteBscInfoVO;
	}
}
